package com.youbug.mall.pms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.youbug.common.vo.QueryVo;
import com.youbug.mall.pms.entity.AttrGroup;
import com.youbug.mall.pms.mapper.AttrGroupMapper;
import com.youbug.mall.pms.service.IAttrGroupService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

/**
 * <p>
 * 属性分组 服务实现类
 * </p>
 *
 * @author youbug
 * @since 2023-07-08
 */
@Service
public class AttrGroupServiceImpl extends ServiceImpl<AttrGroupMapper, AttrGroup> implements IAttrGroupService {

    @Override
    public IPage<AttrGroup> getAttrGroupPage(QueryVo<Long> queryVo) {

        Page<AttrGroup> paramPage = new Page<>();

        paramPage.setCurrent(queryVo.getCurrentPage());

        paramPage.setSize(queryVo.getPageSize());

        QueryWrapper<AttrGroup> wrapper = new QueryWrapper<>();

        if(!ObjectUtils.isEmpty(queryVo.getPayload())){

            wrapper.eq("catelog_id", queryVo.getPayload());
        }

        Page<AttrGroup> page = this.page(paramPage, wrapper);

        return page;
    }
}
